<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name = "format-detection" content = "telephone=no">
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <style>
        html, body {
            background-color: #f8f8f8;
        }
        .search_p {
        	height: 35px;
        	line-height: 41px;
        	font-size: 13px;
        	color: #333;
        	text-align: center;
            display: none;
        }
        .main ul li {
        	margin-bottom: 6px;
        }
        .order_info {
        	padding: 15px;
        	background-color: #fff;
        }
        .order_info .title_box {
        	display: -webkit-box;
        	display: -webkit-flex;
        	margin-bottom: 15px;
        }
        .order_info .title_box .title_boxl {
			width: 0;
			flex: 1;
			-webkit-flex: 1;
			box-flex: 1;
			-webkit-box-flex: 1;
        }
        .order_info .title_box .title_boxl .time {
        	font-size: 12px;
        	color: #999;
        }
        .order_info .title_box .title_boxr {
			color: #999;
			font-size: 13px;
			padding-top: 2px;
			padding-left: 5px;
        }
        .order_info .info_box {
        	font-size: 13px;
        	color: #333;
        }
        .order_info .info_box span {
        	color: #e62442;
        }
        .order_info .info_box .info {
        	padding-bottom: 10px;
        }
        .order_info .info_box .info span {
        	margin-left: 8px;
        }
		.order_info .info_box .address {
        	padding-bottom: 17px;
        }
        .order_info .goods_info {
        	display: -webkit-box;
        	display: -webkit-flex;
        	align-items: center;
        }
        .order_info .goods_info .goods_infol {
        	width: 0;
        	flex: 1;
        	-webkit-flex: 1;
        	box-flex: 1;
        	-webkit-box-flex: 1;
        	font-size: 12px;
        	color: #999;
        }
        .order_info .goods_info .goods_infor {
        	font-size: 17px;
        	color: #e62442;
        	padding-left: 5px;
        }
        .staff_info {
        	background-color: #fff;
        	padding: 0 14px;
        	border-top: 1px solid #e8e8e8;
        }
        .staff_info .staff_box {
        	height: 40px;
        	line-height: 40px;
        	overflow: hidden;
        }
        .staff_info .staff_box .staff_boxl {
        	height: 40px;
        	float: left;
        	display: -webkit-box;
        	-webkit-box-align: center;
        }
        .staff_info .staff_box .staff_boxl .img_box {
        	width: 21px;
        	height: 21px;
        	border-radius: 50%;
        	overflow: hidden;
        	margin-right: 5px;
        }
        .staff_info .staff_box .staff_boxl .img_box img {
			width: 100%;
			height: 100%;
			object-fit: cover;
			display: block;
        }
        .staff_info .staff_box .staff_boxl span {
        	font-size: 13px;
        	color: #999;
        	display: block;
        }
        .staff_info .staff_box .staff_boxr {
        	height: 40px;
        	float: right;
        	display: -webkit-box;
        	-webkit-box-align: center;
        }
        .staff_info .staff_box .staff_boxr img {
        	width: 13px;
        	display: block;
        }
        .confirm_box {
        	background-color: #fff;
        	margin-top: 6px;
        }
        .staff_div {
        	padding: 15px;
        	display: -webkit-box;
        	display: -webkit-flex;
        }
        .staff_div .staff_divl .staff_img {
			width: 40px;
			height: 40px;
			border-radius: 50%;
			overflow: hidden;
			border: 1px solid #d3d3d3;
        }
        .staff_div .staff_divl .staff_img img {
        	width: 100%;
        	height: 100%;
        	object-fit: cover;
        }
        .staff_div .staff_divc {
        	width: 0;
        	flex: 1;
        	-webkit-flex: 1;
        	box-flex: 1;
        	-webkit-box-flex: 1;
        	padding: 0 10px;
        }
        .staff_div .staff_divc .name {
        	font-size: 15px;
        	color: #333;
        	margin-bottom: 6px;
        }
        .staff_div .staff_divc .phone {
        	color: #999;
        	font-size: 12px;
        	margin-bottom: 14px;
        }
        .staff_div .staff_divc .text {
        	color: #333;
        	font-size: 13px;
        }
        .staff_div .staff_divr .num_p {
			font-size: 12px;
			color: #999;
			margin-bottom: 10px;
			padding-top: 6px;
        }
        .staff_div .staff_divr .num {
			color: #f0b925;
			font-size: 16px;
        }
        .confirm_box .confirm_boxb {
        	overflow: hidden;
        	padding: 0 15px 15px;
        }
        .confirm_box .confirm_boxb .btn {
        	width: 67px;
        	height: 22px;
        	line-height: 22px;
        	float: right;
        	text-align: center;
        	border-radius: 5px;
			font-size: 12px;
			color: #333;
			border: 1px solid #999;
        }
    </style>
</head>
<body>
    <div class="search_p">搜索到<span class="search_num">0</span>个结果</div>
    <div class="main">
    	<ul id="order_ul">
<!--     		<li>
    			<div class="order_info">
		    		<div class="title_box">
		    			<div class="title_boxl">
		    				<div class="time">2017--09-07 11:12:12</div>
		    			</div>
		    			<div class="title_boxr">待取餐</div>
		    		</div>
		    		<div class="info_box">
		    			<div class="info">张先生<span>13333333333</span></div>
		    			<div class="address">北京市海淀区龙翔路泰祥商务楼508</div>
		    		</div>
		    		<div class="goods_info">
		    			<div class="goods_infol">鱼香肉丝、宫爆鸡丁等3样菜品</div>
		    			<div class="goods_infor">RM 29.5</div>
		    		</div>
		    	</div>
                <div class="staff_info" onclick="lookStaff(this);" tapmode>
                    <div class="staff_box">
                        <div class="staff_boxl">
                            <div class="img_box">
                                <img src="../image/temp/1.png">
                            </div>
                            <span>查看骑手信息</span>
                        </div>
                        <div class="staff_boxr">
                            <img src="../image/bottom.png">
                        </div>
                    </div>
                </div>
		    	<div class="confirm_box" style="display: none;">
		    		<div class="confirm_boxt">
		    			<div class="staff_div">
		    				<div class="staff_divl">
		    					<div class="staff_img">
		    						<img src="../image/temp/1.png">
		    					</div>
		    				</div>
		    				<div class="staff_divc">
		    					<div class="name">刘德华</div>
		    					<div class="phone">13333333333</div>
		    					<div class="text">骑手取餐时请扫码确认骑手身份</div>
		    				</div>
		    				<div class="staff_divr">
		    					<div class="num_p">取餐码</div>
		    					<div class="num">65</div>
		    				</div>
		    			</div>
		    		</div>
		    		<div class="confirm_boxb">
		    			<div class="btn">扫码确认</div>
		    		</div>
		    	</div>
    		</li> -->
<!--     		<li>
    			<div class="order_info">
		    		<div class="title_box">
		    			<div class="title_boxl">
		    				<div class="time">2017--09-07 11:12:12</div>
		    			</div>
		    			<div class="title_boxr">已完成</div>
		    		</div>
		    		<div class="info_box">
		    			<div class="info">张先生<span>13333333333</span></div>
		    			<div class="address">北京市海淀区龙翔路泰祥商务楼508</div>
		    		</div>
		    		<div class="goods_info">
		    			<div class="goods_infol">鱼香肉丝、宫爆鸡丁等3样菜品</div>
		    			<div class="goods_infor">RM 29.5</div>
		    		</div>
		    	</div>
		    	<div class="staff_info">
		    		<div class="staff_box">
		    			<div class="staff_boxl">
		    				<div class="img_box">
		    					<img src="../image/temp/1.png">
		    				</div>
		    				<span>查看骑手信息</span>
		    			</div>
		    			<div class="staff_boxr">
		    				<img src="../image/bottom.png">
		    			</div>
		    		</div>
		    	</div>
    		</li> -->
    	</ul>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/zepto.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script id="orderTpl" type="text/x-dot-template">
    {{ for(var i=0;i<it.length;i++){ }}
        <li onclick="fnOrderDetail({{=it[i]['id']}},{{=it[i]['status']}});" tapmode>
            <div class="order_info">
                <div class="title_box">
                    <div class="title_boxl">
                        <div class="time">{{=it[i]['create_time']}}</div>
                    </div>
                    <div class="title_boxr">{{=it[i]['status_name']}}</div>
                </div>
                <div class="info_box">
                    <div class="info">{{=it[i]['username']}}<span>{{=it[i]['tel']}}</span></div>
                    <div class="address">{{=it[i]['address_detail']}}</div>
                </div>
                <div class="goods_info">
                    <div class="goods_infol">
                        {{ if(it[i]['goods_type_count'] > 1){ }}
                            {{=it[i]['goods_name']}}等{{=it[i]['goods_type_count']}}样菜品
                        {{ }else{ }}
                            {{=it[i]['goods_name']}}
                        {{ }; }}
                    </div>
                    <div class="goods_infor">RM {{=it[i]['must_pay']}}</div>
                </div>
            </div>
            {{ if(it[i]['staff_id'] > 0){ }}
                <div class="staff_info" onclick="lookStaff(this);" tapmode>
                    <div class="staff_box">
                        <div class="staff_boxl">
                            <div class="img_box">
                                <img src="{{=formatHeadImg(it[i]['staff_img'])}}">
                            </div>
                            <span>查看骑手信息</span>
                        </div>
                        <div class="staff_boxr">
                            <img src="../image/bottom.png">
                        </div>
                    </div>
                </div>
                <div class="confirm_box" style="display: none;">
                    <div class="confirm_boxt">
                        <div class="staff_div">
                            <div class="staff_divl">
                                <div class="staff_img">
                                    <img src="{{=formatHeadImg(it[i]['staff_img'])}}">
                                </div>
                            </div>
                            <div class="staff_divc">
                                <div class="name">{{=it[i]['staff_name']}}</div>
                                <div class="phone">{{=it[i]['staff_phone']}}</div>
                                <div class="text">骑手取餐时请扫码确认骑手身份</div>
                            </div>
                            <div class="staff_divr">
                                <div class="num_p">取餐码</div>
                                <div class="num">{{=it[i]['order_code']}}</div>
                            </div>
                        </div>
                    </div>
                    {{ if(it[i]['status'] == 3){ }}
                        <div class="confirm_boxb">
                            <div class="btn">扫码确认</div>
                        </div>
                    {{ }; }}
                </div>
            {{ }; }}
        </li>
    {{ }; }}
</script>
<script type="text/javascript">
    apiready = function(){
        shop = $api.getStorage('shop_data');
        api.addEventListener({
            name: 'searchResultEvent'
        }, function(ret, err) {
            if (ret) {
                var content = ret.value.content;
                if(content) {
                    api.ajax({
                        url: rootPath+'/api/seller/search_order',
                        method: 'get',
                        data: {
                            values: { 
                                shop_id: shop.id,
                                token : shop.token,
                                content : content
                            },
                        }
                    }, function(ret, err) {
                        if (ret) {
                            var search_num = ret.count?ret.count:0;
                            $('.search_p').show();
                            $('.search_num').text(search_num);
                            $('#order_ul').empty();
                            appendDotData(ret.data,'orderTpl','order_ul',true);

                        } else {
                            alert(JSON.stringify(err.msg));
                        }
                    });
                }
            }
        });
    };

    function lookStaff(this_) {
        $(this_).hide();
        $(this_).next().show();
        event.stopPropagation();
        return false;
    }

    function fnOrderDetail(id,status) {
        if(status == 1 || status == 2 || status == 3 || status == 4) {
            api.openWin({
                name: 'order_detail2',
                url: './order_detail2.html',
                pageParam: {
                    id: id,
                    status : status
                }
            });
        }else{
            api.openWin({
                name: 'order_detail',
                url: './order_detail.html',
                pageParam: {
                    id: id,
                    status : status
                }
            });
        }
    }
</script>
</html>